package com.jyw.business.ast.wechat.controller;

import com.jyw.business.ast.domain.dto.web.AstConsumableClaimDto;
import com.jyw.business.ast.domain.dto.web.AstConsumableClaimPageDto;
import com.jyw.business.ast.domain.dto.web.AstRejectedDto;
import com.jyw.business.ast.domain.vo.web.AstConsumableClaimDetailVo;
import com.jyw.business.ast.domain.vo.web.AstConsumableClaimPageVo;
import com.jyw.business.ast.service.IAstConsumableClaimService;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.BasePage;
import com.jyw.common.core.page.TableDataInfo;
import com.jyw.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资产-耗材-耗材申领Controller
 * 
 * @author system
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/wechat/ast/claim")
@Api(tags = "耗材申领")
public class WehcatAstConsumableClaimController extends BaseController
{
    @Autowired
    private IAstConsumableClaimService astConsumableClaimService;

    /**
     * 查询资产-耗材-耗材申领列表
     */
    @PreAuthorize("@ss.hasPermi('ast:claim:list')")
    @PostMapping("/list")
    @ApiOperation("分页查询")
    public TableDataInfo<AstConsumableClaimPageVo> list(BasePage page, @RequestBody AstConsumableClaimPageDto pageDto)
    {
        startPage();
        List<AstConsumableClaimPageVo> list = astConsumableClaimService.claimPage(pageDto);
        return getDataTable(list);
    }


    /**
     * 获取资产-耗材-耗材申领详细信息
     */
    @PreAuthorize("@ss.hasPermi('ast:claim:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("耗材申领详情")
    public CommonResult<AstConsumableClaimDetailVo> getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(astConsumableClaimService.claimDetail(id));
    }

    /**
     * 新增资产-耗材-耗材申领
     */
    @PreAuthorize("@ss.hasPermi('ast:claim:add')")
    @Log(title = "资产-耗材-耗材申领", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("耗材-申领")
    public CommonResult add(@RequestBody AstConsumableClaimDto dto)
    {
        astConsumableClaimService.claim(dto);
        return CommonResult.success();
    }


    /**
     * 删除资产-耗材-耗材申领
     */
    @PreAuthorize("@ss.hasPermi('ast:claim:remove')")
    @Log(title = "资产-耗材-耗材申领", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    @ApiOperation("撤销")
    public CommonResult revoke(@PathVariable Long id)
    {
        astConsumableClaimService.revoke(id);
        return CommonResult.success();
    }

}
